[Android]problem when delete contacts,please help me

Posted by Enchor on Stack Overflow See other posts from Stack Overflow or by Enchor
Published on 2010-06-17T03:05:13Z Indexed on 2010/06/17 3:13 UTC
Read the original article Hit count: 327

Filed under:
|

I have been working with Android contacts. I am able to show them, update but when I want to delete any, it is not deleted completely. In Contacts application is shown as (Unknown) without any data. Here is my example:

ArrayList ops = new ArrayList(); ops.add(ContentProviderOperation.newDelete(Data.CONTENT_URI) .withSelection(Data.CONTACT_ID + "=?", new String[]{selectedid}) .build()); getContentResolver().applyBatch(ContactsContract.AUTHORITY, ops);

Should I do anything else to delete contact entirely? It seems that these code delete info in table ContactsContract.Data but it does not delete element related in table ContactsContract.Contacts or ContactsContract.RawContacts.how can i do to delete an contact completely?

============================================================================

also, i tried deprecated method. It dose work, but i do not want to do so. Here is the sample code:

ContentResolver contentResolver = m_cContent.getContentResolver(); contentResolver.delete(People.CONTENT_URI, People.NAME + "=?", new String[] { SelectedName });

and if i modify this code to ContentResolver contentResolver = m_cContent.getContentResolver(); contentResolver.delete(ContactsContract.Contacts, ContactsContract.Contacts._ID + "=?", new String[] { Selectedid }); It has no effect.

Does it mean that one can only delete a contact by name instead of by its id? What on earth can i do to delete contact?

Thanks, Enchor

© Stack Overflow or respective owner

Related posts about android

Related posts about contacts